<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>发布公告信息</title>
	<style type="text/css">
	body{
		background-color: white;
	}
	#mainform{
		text-align:left;
		font-size: 22px;
		background-color: white;
		width: 100%;
		margin: 0 auto;
		min-height: 500px;
	}
	#mainform form{
		padding-top: 50px;
		text-align: center;
	}
	#main_input{
		width: 400px;
		height: 30px;
		margin-bottom: 30px;
	}
	#main_sub{
		margin-top: 20px;
		margin-bottom: 20px;
	}
</style>
</head>
<body>
<!--加载头部信息-->
<?php
include_once("header.php");
?>
<!--发布主题中间显示内容-->
<div id="mainform">
<form action="" method="post">
<input type="text" name="title" id="main_input" placeholder="公告标题"><br/><br/>
<textarea name="description" rows="15" cols="80" placeholder="请输入公告内容"></textarea>
<br/><br/>
<input type="submit" name="submit" value="点击发布" id="main_sub">
</form>
</div>
<?php
	if(isset($_POST["submit"])&&$_POST["submit"]=="点击发布"){
	$subjectid=time();
	$title=$_POST["title"];
	date_default_timezone_set("Asia/Shanghai");
	$dates=date("Y-m-d H:m:s");
	$description=$_POST["description"];
	$questioner=$_COOKIE["username"];//这里从cookie里获取登陆用户姓名
	//写入到数据库subject表
	$insertintosubject="insert into notice(subjectid,title,description,dates,questioner,answers) values('$subjectid','$title','$description','$dates','$questioner',0)";
	include_once("database.php");
	mysql_query($insertintosubject) or die("用户发表公告失败:".mysql_error()."<br/>");
	//跳转到主界面
	header("Refresh:2;url=index.php");
	exit;
}
	
?>
<!--加载底部信息-->
<?php
include_once("footer.php");
?>
</body>
</html>